package com.ebocy.hammer.battle.fight.message;

import java.util.Collection;

import com.ebocy.hammer.core.GameCache;
import com.ebocy.hammer.core.constants.GameMessageCode;
import com.ebocy.hammer.core.domain.GamePlayer;
import com.ebocy.hammer.core.message.AbstractS2CMessage;
/**
 * 进入战斗前玩家坐标信息
 * @author Qingrong Hou
 *
 * Jun 16, 2012
 */
public class S2CMemberCoodinateMessage extends AbstractS2CMessage {
	private String mapName;
	private Collection<Long> member;

	public S2CMemberCoodinateMessage(String mapName, Collection<Long> member){
		this.mapName = mapName;
		this.member = member;
	}

	@Override
	protected void writeMessage() {
		writeShort((short)member.size());
		for (Long temp : member) {
			GamePlayer gamePlayer = GameCache.getInstance().getCache(temp);
			writeString(String.valueOf(gamePlayer.getGamePlayerId()));
			writeShort(gamePlayer.getX());
			writeShort(gamePlayer.getY());
			writeByte(gamePlayer.getTeamId());
		}
	}

	@Override
	public short getMessageCode() {
		return GameMessageCode.BATTLE_MEMBER_COORDINATE;
	}

}
